package cn.iocoder.yudao.module.mqtt.dal.mysql.config;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.mqtt.dal.dataobject.config.MqttConfig2DO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.mqtt.controller.admin.config.vo.*;

/**
 * MQTT配置 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface MqttConfig2Mapper extends BaseMapperX<MqttConfig2DO> {

    default PageResult<MqttConfig2DO> selectPage(ConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MqttConfig2DO>()
                .likeIfPresent(MqttConfig2DO::getName, reqVO.getName())
                .likeIfPresent(MqttConfig2DO::getUsername, reqVO.getUsername())
                .eqIfPresent(MqttConfig2DO::getPassword, reqVO.getPassword())
                .eqIfPresent(MqttConfig2DO::getUrl, reqVO.getUrl())
                .eqIfPresent(MqttConfig2DO::getSubClientId, reqVO.getSubClientId())
                .eqIfPresent(MqttConfig2DO::getSubTopics, reqVO.getSubTopics())
                .eqIfPresent(MqttConfig2DO::getPubClientId, reqVO.getPubClientId())
                .eqIfPresent(MqttConfig2DO::getIsOnline, reqVO.getIsOnline())
                .eqIfPresent(MqttConfig2DO::getEnabled, reqVO.getEnabled())
                .eqIfPresent(MqttConfig2DO::getDescription, reqVO.getDescription())
                .betweenIfPresent(MqttConfig2DO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MqttConfig2DO::getId));
    }
}